import Vue from 'vue'
import Router from 'vue-router'


// 导入刚才编写的组件
import AppIndex from  '../components/home/Appindex'
import Login from  '../components/login'
import Home from '../components/Home'
import LibraryIndex from '../components/library/LibraryIndex'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/index',
      component: AppIndex,
      meta: {
        requireAuth: true
      }
    },
    {
      path:'/home',
      name:'Home',
      component:Home,
      //home页面并不需要被访问,只是作为其他组件的父组件
      redirect:'/index',
      children:[
        {
          path:'/index',
          name:'AppIndex',
          component:AppIndex,
          meta:{
            requireAuth:true
          }
        },
        {
        path:'/library',
        name:'Library',
        component:LibraryIndex,
        meta:{
            requireAuth:true
          }
        }
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    }
    ,
    {
      path: '/register',
      name: 'Register',
      component: () => import('../components/Register')
    }
  ]
})
